/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.goods.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.goods.entity.ZtAddr;
import com.jeesite.modules.goods.entity.ZtFans;
import com.jeesite.modules.goods.service.ZtFansService;
import com.jeesite.modules.xcxAdmin.entity.ZtAdmin;
import com.jeesite.modules.xcxAdmin.service.ZtAdminService;

/**
 * 测试数据Controller
 * 
 * @author ThinkGem
 * @version 2018-04-22
 */
@Controller
@RequestMapping(value = "${adminPath}/ztFans")
public class ZtFansController extends BaseController {

	/*@Autowired
	private ZtFansService ztFansService;*/
	@Autowired
	ZtAdminService ztAdminService;

	/**
	 * 获取数据
	 */
	@ModelAttribute
	public ZtAdmin get(String id, boolean isNewRecord) {
		ZtAdmin ztAdmin=new ZtAdmin();
		ztAdmin.setId(id);
		return ztAdminService.get(ztAdmin);
	}

	/**
	 * 查询列表
	 */
	@RequestMapping(value = { "list", "" })
	public String list(ZtAdmin ztAdmin, Model model,HttpSession session) {
		if(ztAdmin!=null&&ztAdmin.getLastadmin()!=null){
			session.setAttribute("ztFansAdminid", ztAdmin.getLastadmin());
		}else{
			if(ztAdmin==null){ztAdmin=new ZtAdmin();}
			ztAdmin.setLastadmin(session.getAttribute("ztFansAdminid").toString());
		}
		
		model.addAttribute("ztAdmin", ztAdmin);
		
		return "modules/ztFans/ztFansList";
	}

	/**
	 * 查询列表数据
	 */
	
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<ZtAdmin> listData(ZtAdmin ztAdmin, HttpServletRequest request,
			HttpServletResponse response,Model model,HttpSession session) {
		
		//session.getAttribute("ztAdminId");
		
		
		//List<ZtAdmin> ztAdminList=ztAdminService.getMyFansList(ztAdmin);
		Page<ZtAdmin> page = ztAdminService.findPage(new Page<ZtAdmin>(request,
				response), ztAdmin);
		
		
		return page;
	}

	
}